<template>
	<view class="quyu">
		<div class="nav">
		  <uni-icons
		    class="icon"
		    @click="huitui"
		    color="#fff"
		    ;
		    type="back"
		    size="20"
		  ></uni-icons>
		  <text class="fabu">选择区域</text>
		</div>

		<view class="box2">
      <img
        class="imgss"
        src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F52bfd348-fe07-4da5-9902-9827765ccccf%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1703936615&t=1fa0593cd66842fef2934e553a13a79c"
        alt=""
      />

      <view class="scroll">
        <uni-title
          color="#fff"
          type="h2"
          title="请选择区域"
          align="center"
        ></uni-title>

        <view class="bottn">
          <view class="b1" v-for="(item, index) in quData" :key="index"  @click="navtiage(item.id)">
            {{ item.area }}区
          </view>
        </view>
      </view>
    </view>
	</view>
</template>

<script setup>
import {ref,onMounted} from 'vue';

  const path = uni.getStorageSync("path");
  //回退页面
const huitui = () => {
  uni.navigateTo({ url: path });
}
  
const quData = ref();

// 调用接口拿到数据
onMounted(() => {
	const arer = [];
	uni.request({
		url:'http://10.31.71.52:7002/housing',
		method:'GET',
		success:(res)=>{
            // console.log(res,'===============区域数据');
			const data = res.data.data;
			//使用for循环拿到所有的数据
			for (let i = 0; i < data.length; i++) {
				arer.push(res.data.data);
			}
            
			quData.value = data;
		}
	})
	console.log(quData,'================区域数据');
})

//回退页面显示
const navtiage =(id)=>{
 const newdata = quData.value.find(item=>item.id === id);
 const data = newdata.area 
uni.navigateTo({url:path})
uni.setStorageSync('quyu',data);
}
</script>

<style lang="scss">
.quyu{
	width: 100vw;
	height: 100vh;
	display: flex;
	flex-direction: column;
	position: relative;
	.box2 {
    flex: 1;
    position: relative;
    .scroll {
      width: 100%;
      height: 100%;
      background: rgba(33, 31, 31, 0.4);
      position: absolute;
      top: 0;
      left: 0;
    }
  }
  .imgss{
	width: 100%;
	height: 100%;
  }
  .bottn {
    width: 100vw;
    height: 320px;
    background-color: #fff;
    position: absolute;
    bottom: 0;
    left: 0;
    overflow: auto;
    box-shadow: 0 5px 15px 5px #000000;
    .b1 {
      width: 100vw;
      height: 40px;
      border-top: 1px solid #ccc;
      text-align: center;
      line-height: 30px;
      background: linear-gradient(to bottom, #f9f5f5, #f4f4f4);
    }
  }

.nav {
    width: 100vw;
    height: 100px;
    background: linear-gradient(to right, #3e85ef, rgb(46, 175, 255));
    position: relative;
    .fabu {
      position: absolute;
      left: 50%;
      top: 60%;
      transform: translate(-50%, -50%);
      color: #fff;
    }
    .icon {
      position: absolute;
      top: 50%;
      left: 10px;
    }
  }
}


</style>
